<?php include_once './header.php'; ?>


<form id="filtrar" action="" method="POST"> 
<select name="ciudad">
<option value="Todo">..</option>
<option value="All">All</option>
<option value="Bogota">Bogota</option>
<option value="Cartagena">Cartagena</option>
<option value="Medellin">Medellin</option>
<option value="Panama">Panama</option>
<option value="Todo">Cargar Todo</option>
</select>
<input type='submit' value='Filtrar' /><input type='hidden' value='Ciudad' name='filtrar' />
</form> 

<?php 
include('config.php'); 

$result = ""; 
if (isset($_POST['filtrar'])){
	foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); }
	$filtro = $_POST['ciudad'];
	if($filtro == "Todo"){
		$result = mysql_query("SELECT * FROM `serviciosadicionales`") or trigger_error(mysql_error()); 
	}else{
		$result = mysql_query("SELECT * FROM `serviciosadicionales` where ciudadServicio = '$filtro' ") or trigger_error(mysql_error()); 
	}
	
}

echo "<table border=1 >"; 
echo "<tr>"; 
echo "<td><b>Id</b></td>"; 
echo "<td><b>Nombre</b></td>"; 
echo "<td><b>Descripcion</b></td>"; 
echo "<td><b>Ciudad</b></td>";
echo "<td><b>Url</b></td>"; 
echo "<td><b>Precio</b></td>"; 
echo "<td><b>Gratuito</b></td>"; 
echo "<td><b>Periodicidad</b></td>"; 
echo "</tr>"; 

while($row = mysql_fetch_array($result)){ 
foreach($row AS $key => $value) { $row[$key] = stripslashes($value); } 
echo "<tr>";  
echo "<td valign='top'>" . nl2br( $row['idServicio']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['nombreServicio']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['descServicio']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['ciudadServicio']) . "</td>";
if (nl2br( $row['urlServicio']) != ''){
	echo "<td valign='top'><a href='http://" . nl2br( $row['urlServicio']) . "' target='_blank'>visit</a></td>";  
}else{
	echo "<td valign='top'>" . nl2br( $row['urlServicio']) . "</td>";  
}
echo "<td valign='top'>" . nl2br( $row['precioServicio']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['gratuito']) . "</td>";  
echo "<td valign='top'>" . nl2br( $row['periodicidad']) . "</td>";  
echo "<td valign='top'><a href=editService.php?idServicio={$row['idServicio']}>Edit</a></td><td><a href=deleteService.php?idServicio={$row['idServicio']}>Delete</a></td> "; 
echo "</tr>"; 
} 
echo "</table>"; 
echo "<a href=newService.php>New Row</a>"; 
?>

<?php include_once './footer.php'; ?>